﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PIS.TechGrid.Models;

namespace PIS.TechGrid.Studies.Validation
{
    [TestClass]
    public class ModelValidationTest
    {
        [TestMethod]
        public void ModelValidation()
        {
            User user = new User()
            {
                Code = "RAY_Code_RAY_Code_RAY_Code_RAY_Code_RAY_Code_RAY_Code",
                Name = "Ray",
                Email = "ray@gooooooooooooooooooooooooooooooooooooooooooooooooooooooooogle.com"
            };

            IList<ValidationResult> validationResults = new List<ValidationResult>();
            ValidationContext validationContext = new ValidationContext(user);

            bool result = Validator.TryValidateObject(user, validationContext, validationResults, true);
            Assert.IsFalse(result);
        }
    }
}
